<!DOCTYPE html>
<html lang="en" style="font-size: 100px">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rem适配</title>
    <style>
        *{margin:0;padding:0}
        #banner{
            width: 3.35rem;
            height: 1.44rem;
            margin: 0.97rem auto;
            background: rgb(174, 209, 226);
        }
    </style>
</head>
<body>
    <div id="banner"></div>

    <script>
        function adapter(){
            //计算当前设备下, 根标签的大小
            let fontSize = document.documentElement.clientWidth * 100 / 375;
            //设置根标签的大小
            document.documentElement.style.fontSize = fontSize + "px";
        }
        //立即执行
        adapter();
        //绑定事件
        window.onresize = adapter;


    </script>
</body>
</html>